// pages/equipment/add/add.js
import {
  validate
} from '../../../common/js/validate'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    name: '',
    patient: '',
    pay: '',
    disabledSubmit: true,
    optionsMedical: [{
        label: "张医生",
        value: "张医生"
      },
      {
        label: "王医生",
        value: "王医生"
      },
      {
        label: "孙医生",
        value: "孙医生"
      },
      {
        label: "李医生",
        value: "李医生"
      },
      {
        label: "周医生",
        value: "周医生"
      },
      {
        label: "吴医生",
        value: "吴医生"
      },
    ],
  },

  showModal(e) {
    const id = e.currentTarget.dataset.id
    this.selectComponent('#' + id).show()
  },
  /**
   * 输入事件
   */
  bindinput(e) {
    const name = e.currentTarget.dataset.name
    this.setData({
      [name]: e.detail.value
    })

    this.updateDisabled()
  },
  updateDisabled() {
    this.setData({
      disabledSubmit: !(this.data.patient && this.data.pay && this.data.medical)
    })
  },
  bindChange(e) {
    let name = e.currentTarget.dataset.name
    let value = e.detail.value
    this.setData({
      [name]: value
    })
    this.updateDisabled()
  },
  bindtapConfirm() {
    if (this.data.disabledSubmit) {
      return
    }
    this.selectComponent('#dialog').show()
    setTimeout(() => {
      wx.navigateTo({
        url: '/pages/appointmentReferral/order/detail/after/after?from=confirm',
      })
    }, 2000);
  }
})